<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>签到任务系统 - 后台管理与会员打卡</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
        }
        
        :root {
            --primary: #3498db;
            --secondary: #2ecc71;
            --accent: #9b59b6;
            --light: #f8f9fa;
            --dark: #2c3e50;
            --gray: #7f8c8d;
            --border: #e0e0e0;
            --warning: #f39c12;
            --danger: #e74c3c;
            --text: #34495e;
        }
        
        body {
            font-size: 14px;
            color: var(--text);
            line-height: 1.6;
            background: #f5f7fa;
            min-height: 100vh;
        }
        
        .container {
            max-width: 750px;
            margin: 0 auto;
            padding: 0 15px;
        }
        
        .header {
            background: linear-gradient(135deg, var(--primary), #2980b9);
            color: white;
            padding: 20px 15px;
            border-radius: 0 0 20px 20px;
            margin-bottom: 20px;
        }
        
        .top-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        
        .logo {
            display: flex;
            align-items: center;
            font-size: 20px;
            font-weight: 700;
        }
        
        .logo i {
            margin-right: 10px;
            font-size: 24px;
        }
        
        .user-actions {
            display: flex;
            gap: 15px;
        }
        
        .icon-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 16px;
        }
        
        .view-switcher {
            display: flex;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 30px;
            padding: 5px;
            margin-top: 10px;
        }
        
        .view-btn {
            flex: 1;
            text-align: center;
            padding: 8px 0;
            border-radius: 30px;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .view-btn.active {
            background: white;
            color: var(--primary);
            font-weight: 500;
        }
        
        /* 管理员视图样式 */
        .admin-view {
            display: block;
        }
        
        .member-view {
            display: none;
        }
        
        .section {
            background: white;
            border-radius: 16px;
            padding: 20px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
            margin-bottom: 20px;
        }
        
        .section-title {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid var(--border);
        }
        
        .section-title h2 {
            font-size: 18px;
            font-weight: 700;
            display: flex;
            align-items: center;
        }
        
        .section-title h2 i {
            margin-right: 10px;
            color: var(--primary);
        }
        
        .section-title .action-btn {
            margin-left: auto;
            background: var(--primary);
            color: white;
            border: none;
            border-radius: 8px;
            padding: 8px 15px;
            font-size: 14px;
            cursor: pointer;
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        .form-label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
        }
        
        .form-control {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid var(--border);
            border-radius: 10px;
            font-size: 15px;
        }
        
        .form-control:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
        }
        
        .datetime-group {
            display: flex;
            gap: 10px;
        }
        
        .datetime-group .form-control {
            flex: 1;
        }
        
        .btn {
            display: block;
            width: 100%;
            padding: 14px;
            border-radius: 10px;
            border: none;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
            text-align: center;
        }
        
        .btn-primary {
            background: var(--primary);
            color: white;
        }
        
        .location-map {
            height: 200px;
            background: #e0e7ff;
            border-radius: 10px;
            margin: 20px 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary);
            font-weight: 500;
        }
        
        .location-map i {
            font-size: 40px;
            margin-right: 10px;
        }
        
        .tasks-list {
            max-height: 400px;
            overflow-y: auto;
        }
        
        .task-item {
            display: flex;
            padding: 15px 0;
            border-bottom: 1px solid var(--border);
        }
        
        .task-item:last-child {
            border-bottom: none;
        }
        
        .task-icon {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background: #e0f7fa;
            color: var(--primary);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            margin-right: 15px;
            flex-shrink: 0;
        }
        
        .task-info {
            flex: 1;
        }
        
        .task-title {
            font-weight: 600;
            margin-bottom: 5px;
        }
        
        .task-meta {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            font-size: 12px;
            color: var(--gray);
            margin-top: 8px;
        }
        
        .meta-item {
            display: flex;
            align-items: center;
        }
        
        .meta-item i {
            margin-right: 5px;
        }
        
        .task-actions {
            display: flex;
            flex-direction: column;
            gap: 8px;
            margin-left: 10px;
        }
        
        .action-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #f1f5f9;
            color: var(--gray);
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .action-btn:hover {
            background: var(--primary);
            color: white;
        }
        
        .stats-cards {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 12px;
            margin-bottom: 20px;
        }
        
        .stat-card {
            background: white;
            border-radius: 12px;
            padding: 15px;
            text-align: center;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
        }
        
        .stat-value {
            font-size: 24px;
            font-weight: 700;
            margin-bottom: 5px;
        }
        
        .stat-label {
            font-size: 12px;
            color: var(--gray);
        }
        
        .card-1 .stat-value {
            color: var(--primary);
        }
        
        .card-2 .stat-value {
            color: var(--secondary);
        }
        
        .card-3 .stat-value {
            color: var(--accent);
        }
        
        /* 会员视图样式 */
        .checkin-card {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
            border-radius: 16px;
            padding: 25px;
            color: white;
            margin-bottom: 20px;
            text-align: center;
        }
        
        .checkin-title {
            font-size: 22px;
            font-weight: 700;
            margin-bottom: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .checkin-title i {
            margin-right: 10px;
        }
        
        .distance-info {
            font-size: 32px;
            font-weight: 700;
            margin: 20px 0;
        }
        
        .distance-label {
            font-size: 14px;
            opacity: 0.9;
        }
        
        .checkin-btn {
            background: white;
            color: var(--primary);
            border: none;
            border-radius: 30px;
            padding: 15px;
            font-size: 18px;
            font-weight: 700;
            width: 80%;
            margin: 20px auto;
            cursor: pointer;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
            transition: all 0.3s;
        }
        
        .checkin-btn:disabled {
            background: #cccccc;
            cursor: not-allowed;
        }
        
        .checkin-btn.success {
            background: var(--secondary);
            color: white;
        }
        
        .task-detail {
            background: white;
            border-radius: 16px;
            padding: 20px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
            margin-bottom: 20px;
        }
        
        .detail-item {
            display: flex;
            margin-bottom: 15px;
        }
        
        .detail-label {
            width: 100px;
            color: var(--gray);
            font-size: 14px;
        }
        
        .detail-value {
            flex: 1;
            font-weight: 500;
        }
        
        .history-list {
            max-height: 300px;
            overflow-y: auto;
        }
        
        .history-item {
            display: flex;
            padding: 15px 0;
            border-bottom: 1px solid var(--border);
        }
        
        .history-item:last-child {
            border-bottom: none;
        }
        
        .history-date {
            width: 100px;
            font-weight: 500;
        }
        
        .history-info {
            flex: 1;
        }
        
        .history-location {
            font-weight: 500;
            margin-bottom: 3px;
        }
        
        .history-time {
            font-size: 12px;
            color: var(--gray);
        }
        
        .history-status {
            display: flex;
            align-items: center;
            font-size: 12px;
            padding: 3px 8px;
            border-radius: 10px;
        }
        
        .status-success {
            background: #d1fae5;
            color: #047857;
        }
        
        .status-fail {
            background: #fee2e2;
            color: #b91c1c;
        }
        
        .chart-container {
            height: 200px;
            margin: 20px 0;
        }
        
        .footer {
            text-align: center;
            padding: 20px 0;
            color: var(--gray);
            font-size: 12px;
        }
        
        /* 响应式调整 */
        @media (max-width: 480px) {
            .stats-cards {
                grid-template-columns: 1fr;
            }
            
            .datetime-group {
                flex-direction: column;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="top-bar">
                <div class="logo">
                    <i class="fas fa-map-marker-alt"></i>
                    签到任务系统
                </div>
                <div class="user-actions">
                    <div class="icon-btn">
                        <i class="fas fa-bell"></i>
                    </div>
                    <div class="icon-btn">
                        <i class="fas fa-user"></i>
                    </div>
                </div>
            </div>
            
            <div class="view-switcher">
                <div class="view-btn active" id="adminViewBtn">管理员后台</div>
                <div class="view-btn" id="memberViewBtn">会员打卡</div>
            </div>
        </div>
        
        <!-- 管理员后台视图 -->
        <div class="admin-view" id="adminView">
            <div class="section">
                <div class="section-title">
                    <h2><i class="fas fa-plus-circle"></i> 创建签到任务</h2>
                </div>
                
                <div class="form-group">
                    <label class="form-label">任务名称</label>
                    <input type="text" class="form-control" id="taskName" placeholder="输入签到任务名称">
                </div>
                
                <div class="form-group">
                    <label class="form-label">签到地点</label>
                    <input type="text" class="form-control" id="locationName" placeholder="输入地点名称">
                </div>
                
                <div class="form-group">
                    <label class="form-label">详细地址</label>
                    <input type="text" class="form-control" id="locationAddress" placeholder="输入详细地址">
                </div>
                
                <div class="form-group">
                    <label class="form-label">签到有效时间</label>
                    <div class="datetime-group">
                        <input type="datetime-local" class="form-control" id="startTime">
                        <input type="datetime-local" class="form-control" id="endTime">
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">签到范围（米）</label>
                    <input type="number" class="form-control" id="checkinRadius" placeholder="输入签到有效范围" value="100">
                </div>
                
                <div class="form-group">
                    <label class="form-label">地点位置</label>
                    <div class="location-map">
                        <i class="fas fa-map-marked-alt"></i>
                        <span>点击地图选择位置</span>
                    </div>
                </div>
                
                <button class="btn btn-primary" id="createTaskBtn">创建签到任务</button>
            </div>
            
            <div class="section">
                <div class="section-title">
                    <h2><i class="fas fa-tasks"></i> 签到任务管理</h2>
                    <button class="action-btn">
                        <i class="fas fa-sync-alt"></i>
                    </button>
                </div>
                
                <div class="stats-cards">
                    <div class="stat-card card-1">
                        <div class="stat-value">12</div>
                        <div class="stat-label">进行中</div>
                    </div>
                    <div class="stat-card card-2">
                        <div class="stat-value">86</div>
                        <div class="stat-label">总签到</div>
                    </div>
                    <div class="stat-card card-3">
                        <div class="stat-value">5</div>
                        <div class="stat-label">已结束</div>
                    </div>
                </div>
                
                <div class="tasks-list">
                    <div class="task-item">
                        <div class="task-icon">
                            <i class="fas fa-store"></i>
                        </div>
                        <div class="task-info">
                            <div class="task-title">星巴克门店签到</div>
                            <div class="task-desc">到任意星巴克门店进行签到</div>
                            <div class="task-meta">
                                <div class="meta-item">
                                    <i class="fas fa-map-marker-alt"></i> 所有门店
                                </div>
                                <div class="meta-item">
                                    <i class="fas fa-users"></i> 42人已签到
                                </div>
                                <div class="meta-item">
                                    <i class="fas fa-clock"></i> 08:00 - 22:00
                                </div>
                            </div>
                        </div>
                        <div class="task-actions">
                            <div class="action-btn">
                                <i class="fas fa-edit"></i>
                            </div>
                            <div class="action-btn">
                                <i class="fas fa-chart-bar"></i>
                            </div>
                        </div>
                    </div>
                    
                    <div class="task-item">
                        <div class="task-icon">
                            <i class="fas fa-utensils"></i>
                        </div>
                        <div class="task-info">
                            <div class="task-title">周五餐厅打卡</div>
                            <div class="task-desc">指定合作餐厅周五签到</div>
                            <div class="task-meta">
                                <div class="meta-item">
                                    <i class="fas fa-map-marker-alt"></i> 海底捞(中关村店)
                                </div>
                                <div class="meta-item">
                                    <i class="fas fa-users"></i> 28人已签到
                                </div>
                                <div class="meta-item">
                                    <i class="fas fa-clock"></i> 11:00 - 21:00
                                </div>
                            </div>
                        </div>
                        <div class="task-actions">
                            <div class="action-btn">
                                <i class="fas fa-edit"></i>
                            </div>
                            <div class="action-btn">
                                <i class="fas fa-chart-bar"></i>
                            </div>
                        </div>
                    </div>
                    
                    <div class="task-item">
                        <div class="task-icon">
                            <i class="fas fa-gem"></i>
                        </div>
                        <div class="task-info">
                            <div class="task-title">VIP新品体验会</div>
                            <div class="task-desc">VIP会员新品体验签到</div>
                            <div class="task-meta">
                                <div class="meta-item">
                                    <i class="fas fa-map-marker-alt"></i> 王府井旗舰店
                                </div>
                                <div class="meta-item">
                                    <i class="fas fa-users"></i> 16人已签到
                                </div>
                                <div class="meta-item">
                                    <i class="fas fa-clock"></i> 14:00 - 18:00
                                </div>
                            </div>
                        </div>
                        <div class="task-actions">
                            <div class="action-btn">
                                <i class="fas fa-edit"></i>
                            </div>
                            <div class="action-btn">
                                <i class="fas fa-chart-bar"></i>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="section">
                <div class="section-title">
                    <h2><i class="fas fa-chart-line"></i> 签到数据分析</h2>
                </div>
                
                <div class="chart-container">
                    <canvas id="checkinChart"></canvas>
                </div>
            </div>
        </div>
        
        <!-- 会员打卡视图 -->
        <div class="member-view" id="memberView">
            <div class="checkin-card">
                <h2 class="checkin-title">
                    <i class="fas fa-map-marker-alt"></i> 今日签到任务
                </h2>
                <p>星巴克门店签到</p>
                
                <div class="distance-info">
                    125<span style="font-size: 20px;">米</span>
                </div>
                <div class="distance-label">距签到点距离</div>
                
                <button class="checkin-btn" id="checkinBtn">
                    <i class="fas fa-location-dot"></i> 立即签到
                </button>
                
                <div>
                    签到有效范围：100米内
                </div>
            </div>
            
            <div class="task-detail">
                <div class="detail-item">
                    <div class="detail-label">任务名称</div>
                    <div class="detail-value">星巴克门店签到</div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">签到地点</div>
                    <div class="detail-value">星巴克(中关村店)</div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">详细地址</div>
                    <div class="detail-value">北京市海淀区中关村大街15号</div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">有效时间</div>
                    <div class="detail-value">每天 08:00 - 22:00</div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">任务奖励</div>
                    <div class="detail-value">20积分 + 星巴克9折券</div>
                </div>
            </div>
            
            <div class="section">
                <div class="section-title">
                    <h2><i class="fas fa-history"></i> 签到记录</h2>
                </div>
                
                <div class="history-list">
                    <div class="history-item">
                        <div class="history-date">07-30</div>
                        <div class="history-info">
                            <div class="history-location">星巴克(中关村店)</div>
                            <div class="history-time">10:25:34</div>
                        </div>
                        <div class="history-status status-success">成功</div>
                    </div>
                    
                    <div class="history-item">
                        <div class="history-date">07-29</div>
                        <div class="history-info">
                            <div class="history-location">海底捞(中关村店)</div>
                            <div class="history-time">18:45:12</div>
                        </div>
                        <div class="history-status status-success">成功</div>
                    </div>
                    
                    <div class="history-item">
                        <div class="history-date">07-28</div>
                        <div class="history-info">
                            <div class="history-location">王府井旗舰店</div>
                            <div class="history-time">15:30:45</div>
                        </div>
                        <div class="history-status status-success">成功</div>
                    </div>
                    
                    <div class="history-item">
                        <div class="history-date">07-27</div>
                        <div class="history-info">
                            <div class="history-location">星巴克(中关村店)</div>
                            <div class="history-time">09:15:22</div>
                        </div>
                        <div class="history-status status-fail">超出范围</div>
                    </div>
                </div>
            </div>
            
            <div class="section">
                <div class="section-title">
                    <h2><i class="fas fa-award"></i> 我的签到成就</h2>
                </div>
                
                <div class="stats-cards">
                    <div class="stat-card card-1">
                        <div class="stat-value">28</div>
                        <div class="stat-label">总签到</div>
                    </div>
                    <div class="stat-card card-2">
                        <div class="stat-value">15</div>
                        <div class="stat-label">连续签到</div>
                    </div>
                    <div class="stat-card card-3">
                        <div class="stat-value">860</div>
                        <div class="stat-label">总积分</div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="footer">
            <p>© 2023 签到任务系统 | 基于地理位置的服务平台</p>
            <p>技术支持: 400-888-9999 | 工作日 9:00-18:00</p>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 视图切换
            const adminViewBtn = document.getElementById('adminViewBtn');
            const memberViewBtn = document.getElementById('memberViewBtn');
            const adminView = document.getElementById('adminView');
            const memberView = document.getElementById('memberView');
            
            adminViewBtn.addEventListener('click', function() {
                adminViewBtn.classList.add('active');
                memberViewBtn.classList.remove('active');
                adminView.style.display = 'block';
                memberView.style.display = 'none';
            });
            
            memberViewBtn.addEventListener('click', function() {
                memberViewBtn.classList.add('active');
                adminViewBtn.classList.remove('active');
                memberView.style.display = 'block';
                adminView.style.display = 'none';
            });
            
            // 模拟签到功能
            const checkinBtn = document.getElementById('checkinBtn');
            let isChecking = false;
            
            checkinBtn.addEventListener('click', function() {
                if (isChecking) return;
                
                isChecking = true;
                checkinBtn.disabled = true;
                checkinBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> 签到中...';
                
                // 模拟定位过程
                setTimeout(() => {
                    // 75%概率签到成功，25%概率失败
                    const success = Math.random() > 0.25;
                    
                    if (success) {
                        checkinBtn.innerHTML = '<i class="fas fa-check-circle"></i> 签到成功!';
                        checkinBtn.classList.add('success');
                        
                        // 更新距离显示
                        document.querySelector('.distance-info').textContent = '0米';
                        
                        // 添加签到记录
                        const now = new Date();
                        const historyList = document.querySelector('.history-list');
                        const dateStr = `${String(now.getMonth()+1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
                        const timeStr = `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;
                        
                        const newItem = document.createElement('div');
                        newItem.className = 'history-item';
                        newItem.innerHTML = `
                            <div class="history-date">${dateStr}</div>
                            <div class="history-info">
                                <div class="history-location">星巴克(中关村店)</div>
                                <div class="history-time">${timeStr}</div>
                            </div>
                            <div class="history-status status-success">成功</div>
                        `;
                        
                        historyList.insertBefore(newItem, historyList.firstChild);
                        
                        // 更新统计信息
                        document.querySelector('.stat-card.card-1 .stat-value').textContent = 
                            parseInt(document.querySelector('.stat-card.card-1 .stat-value').textContent) + 1;
                        document.querySelector('.stat-card.card-3 .stat-value').textContent = 
                            parseInt(document.querySelector('.stat-card.card-3 .stat-value').textContent) + 20;
                    } else {
                        checkinBtn.innerHTML = '<i class="fas fa-times-circle"></i> 超出范围!';
                        
                        // 添加失败记录
                        const now = new Date();
                        const historyList = document.querySelector('.history-list');
                        const dateStr = `${String(now.getMonth()+1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
                        const timeStr = `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;
                        
                        const newItem = document.createElement('div');
                        newItem.className = 'history-item';
                        newItem.innerHTML = `
                            <div class="history-date">${dateStr}</div>
                            <div class="history-info">
                                <div class="history-location">星巴克(中关村店)</div>
                                <div class="history-time">${timeStr}</div>
                            </div>
                            <div class="history-status status-fail">超出范围</div>
                        `;
                        
                        historyList.insertBefore(newItem, historyList.firstChild);
                    }
                    
                    // 重置按钮
                    setTimeout(() => {
                        checkinBtn.innerHTML = '<i class="fas fa-location-dot"></i> 立即签到';
                        checkinBtn.disabled = false;
                        checkinBtn.classList.remove('success');
                        isChecking = false;
                    }, 3000);
                }, 2000);
            });
            
            // 创建签到任务
            const createTaskBtn = document.getElementById('createTaskBtn');
            createTaskBtn.addEventListener('click', function() {
                const taskName = document.getElementById('taskName').value;
                if (!taskName) {
                    alert('请输入任务名称');
                    return;
                }
                
                alert(`签到任务 "${taskName}" 创建成功！`);
                
                // 清空表单
                document.getElementById('taskName').value = '';
                document.getElementById('locationName').value = '';
                document.getElementById('locationAddress').value = '';
                document.getElementById('checkinRadius').value = '100';
            });
            
            // 图表初始化
            const ctx = document.getElementById('checkinChart').getContext('2d');
            const chart = new Chart(ctx, {
                type: 'bar',
                data: {
                    labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
                    datasets: [{
                        label: '签到次数',
                        data: [24, 32, 18, 27, 39, 43, 28],
                        backgroundColor: '#3498db',
                        borderRadius: 5
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            display: false
                        }
                    },
                    scales: {
                        y: {
                            beginAtZero: true,
                            grid: {
                                drawBorder: false
                            }
                        },
                        x: {
                            grid: {
                                display: false
                            }
                        }
                    }
                }
            });
        });
    </script>
</body>
</html>